package com.starhub.application.model.dto;

import com.starhub.application.model.constants.ModelConstants;
import com.starhub.application.model.enums.ChatTypeEnums;
import com.starhub.common.bean.model.ModelConfig;

import lombok.Builder;
import lombok.Data;

/**   
 * 模型配置创建实体类 用于传递自定义的模型参数
 * @version: V1.0
 * @author: liuhf
 * @time 2025-05-28
 */
@Builder(toBuilder = true)
@Data
public class ModelConfigDto {

    private ModelConfig modelConfig;

    ChatTypeEnums ChatTypeEnum;

    private Double temperature;
    private Integer maxTokens;
    private Double topP;
    private Double frequencyPenalty;
    private Double presencePenalty;
    
    /**
     * 检查参数
     */
    public ModelConfigDto checkParams(){
        if(this.temperature == null || this.maxTokens <= 0 || this.maxTokens > 1){
            this.temperature = ModelConstants.DEFAULT_TEMPERATURE;
        }
        if(this.maxTokens == null || this.maxTokens <= 0){
            this.maxTokens = ModelConstants.DEFAULT_TOKEN;
        }
        if(this.topP == null){
            this.topP = ModelConstants.DEFAULT_TOP_P;
        }
        if(this.frequencyPenalty == null){
            this.frequencyPenalty = ModelConstants.DEFAULT_FREQUENCY_PENALTY;
        }
        if(this.presencePenalty == null){
            this.presencePenalty = ModelConstants.DEFAULT_PRESENCE_PENALTY;
        }
        return this;
    }
}
